#!/usr/bin/env python3
#coding:utf-8

__author__ = 'xmxoxo'

import sys

if __name__ == '__main__':
    pass

n = 12
m = 5
list1 = [i for i in range(1,n+1)]
i = 1
k = 12
lstR = []

while k>1:
    #print (i , end = '')
    i = (i + m - 1  ) % k 
    if i ==0 : i = k
    p = list1[i-1]
    #print ('  i=%d , k = %d , p = %d  ' % (i, k,p))
    #print (list1)
    #print(p)
    lstR.append(p)
    list1.remove(p)
    k = k - 1 #len(list1)
#最的剩下的
lstR.append(list1[0])
print (lstR)